<?php
require_once 'util/perm.php';

require_once 'tpl/use/block/styleCore.php';
require_once 'tpl/use/block/pagerBar.php';
require_once 'util/xhtml.php';

// I don't like having $start and $inc. Could revamp the pager
function skin_ShowPosts( $tnum, $posts, $count, $start, $inc ) {
  styleHead();

  echo linkAt( 'spit.php', null, 'To Fora' ),
       linkAt( 'spit.php', array( 'type' => 'THREAD', 'tnum' => $tnum ), 'To Thread' ),
       linkAt( 'post.php', array( 'tnum' => $tnum ), 'Reply' ); 
  foreach( $posts as $post ) {
    echo "<h1>{$post['title']} on ".  date('d-F-Y', $post['date']) ." by ";
    if( $post['uid'] > 0 ) 
      echo linkAt( 'user.php', array( 'type' => 'SHOW', 'uid' => (int)$post['uid'] ), $post['uname'] ), '</h1><br />';
    else
      echo $post['uname'],'</h1><br />';

    echo "<p>{$post['datum']}</p>";
    if( hasPerm( "post.edit", $_SESSION['user']['perm'], $post['uid']) )
         echo linkAt( 'post.php', array('type' => 'EDIT', 'tnum' => $post['tid'], 'pnum' => $post['rank'] ), 'Edit' );
    if( hasPerm( "post.edit", $_SESSION['user']['perm'], $post['uid']) )
         echo linkAt( 'gulp.php', array('type' => 'POST', 'action[delete]' => true, 'tnum' => $post['tid'], 'pnum' => $post['rank']), 'DELeTE' );
  }
  echo linkAt('post.php', array( 'tnum' => $tnum ), 'Reply' ); 

  pagerBar("spit.php?type=POST&amp;", $tnum, $count, $start, $inc);

  styleFoot();
}
?>
